{% extends 'pc/person/indexOthers.html' %}
{% load static %}
{% block end %}
    <div class="person fl">

        <div class="clearfix">
            <div class="fl left_nav">
                <ul id="follow">
                    <li data-type="" class="active"><a href="javascript:;">关注</a></li>
                    <li data-type="" class=""><a href="javascript:;">粉丝</a></li>

                </ul>
            </div>
            <article class="fr">
                 <div class="blogs">
                     <div class="blogs_head" style="background: url({% static 'img/recommend.png' %})no-repeat 0 50%;">他的关注</div>
                     <div class="follow_main">
                         <ul class="clearfix">

                             {% for foo in count %}
                                    <li class="follow_item">
                                 <dl class="clearfix">
                                     <dt class="fl">
                                         <a target="_blank" title="" href="{% url 'user:author_detaile' foo.id %}">
                                            <img class="follow_item_img" style="background-color: #ccc;" width="50" height="50" alt="" src="{% if foo.user_imag %}
                                            {{ MEDIA_URL }}{{ foo.user_imag }}
                                            {% elif  foo.user_image  %}
                                            {{ foo.user_image }}
                                            {% else %}
                                            {% static 'img/pc-icon.png' %}
                                            {% endif %}">
                                         </a>
                                     </dt>
                                     <dd class="fl"style="text-align: left">
                                         <div class="follow_item_name">
                                            <a target="_blank" title="" alt="" href="{% url 'user:author_detaile' foo.id %}">{{ foo.username }}</a>
                                         </div>
                                         <div class="follow_item_info">
                                             {% load forum %}
                                            <p>文章:{{ foo.article_set|get_counts }}</p>
                                             <p>帖子:{{ foo.forum_set|get_count}}</p>
                                         </div>
                                     </dd>

                                 </dl>
                             </li>
                             {% endfor %}
                         </ul>
                     </div>
                    <div class="follow_main" style="display: none">
                         <ul class="clearfix">
                             {% for foo in floow %}
                                    <li class="follow_item">
                                 <dl class="clearfix">
                                     <dt class="fl">
                                         <a target="_blank" title="" href="{% url 'user:author_detaile' foo.id %}">
                                            <img class="follow_item_img" width="50" height="50" style="background-color: #ccc;" alt="" src="{% if foo.user_imag %}
                                            {{ MEDIA_URL }}{{ foo.user_imag }}
                                            {% elif foo.user_image  %}
                                            {{ foo.user_image }}
                                            {% else %}
                                            {% static 'img/pc-icon.png' %}
                                            {% endif %}">
                                         </a>
                                     </dt>
                                     <dd class="fl"style="text-align: left">
                                         <div class="follow_item_name">
                                            <a target="_blank" title="" alt="" href="{% url 'user:author_detaile' foo.id %}">{{ foo.username }}</a>
                                         </div>
                                         <div class="follow_item_info">
                                             <p>文章:{{ foo.article_set|get_counts }}</p>
                                             <p>帖子:{{ foo.forum_set|get_count }}</p>
                                         </div>
                                     </dd>

                                 </dl>
                             </li>
                             {% endfor %}
                         </ul>
                     </div>
                 </div>
            </article>
        </div>
    </div>

{% endblock %}
{% block js %}
    <script src="{% static 'js/promise.min.js' %}"></script>
    <script src="{% static 'js/sweetalert.min.js' %}"></script>
    <script>
    function flollw (obj){
          $.ajax({
                url:'/person/author/',
                type:'post',
                data:{follow:obj,'username':'{{ request.user.id }}'},
                  headers:{'X-CSRFToken':$.cookie('csrftoken')},
                success:function (data) {
                       if(data.status==403){
                       swal({
                          text: data.message,
                          icon: "error",
                        }).then(function () {
                           window.location.href = "{% url 'index' %}?next={{ request.path }}"
                       })
                    }else{
                    swal({
                          text: data.message,
                          icon: "success",
                        }).then(function () {
                            window.location.reload()
                        })
                     }
                },
                error:function (xhr) {
                    console.log(xhr)
                }
            })
    }
    $(function () {

        $('#follow li').on('click',function () {
             $('.follow_main').siblings('.blogs_head').text('他的'+$(this).text())
            $(this).addClass('active').siblings().removeClass('active')
            var index= $(this).index()
            $('.follow_main').eq(index).show().siblings('.follow_main').hide()
        })

    })
    </script>
{% endblock %}